// 股票数据管理
class StockData {
  constructor() {
      this.data = [];
      this.currentIndex = 0;
      this.generateStockData();
  }

  generateStockData() {
      const basePrice = 100;
      for (let i = 0; i < 50; i++) {
          const change = (Math.random() - 0.5) * 10;
          const open = basePrice + change;
          const close = open + (Math.random() - 0.5) * 5;
          const high = Math.max(open, close) + Math.random() * 3;
          const low = Math.min(open, close) - Math.random() * 3;
          const volume = Math.floor(Math.random() * 1000000) + 500000;
          
          this.data.push({
              date: `2024-10-${i + 1}`,
              open: parseFloat(open.toFixed(2)),
              close: parseFloat(close.toFixed(2)),
              high: parseFloat(high.toFixed(2)),
              low: parseFloat(low.toFixed(2)),
              volume: volume
          });
      }
  }

  getCurrentData() {
      // 返回当前显示的K线数据（最近5根）
      return this.data.slice(this.currentIndex, this.currentIndex + 5);
  }

  getNextData() {
      return this.data[this.currentIndex + 5];
  }

  moveToNext() {
      if (this.currentIndex < this.data.length - 5) {
          this.currentIndex++;
      }
  }

  reset() {
      this.currentIndex = 0;
  }
}

export default StockData;